home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************************/
- /* */
- /* interrupt.c - SCC interrupt routines. */
- /* */
- /* Richard W. Mincher. February 19, 1990. */
- /* */
- /* Copyright © 1990 Apple Computer, Inc. All rights reserved. */
- /* */
- /* */
- /* Once the interrupt routines are complete it might be a good idea */
- /* to convert them to assembler. It remains to be seen how much */
- /* improvement can actually be made. MPW 3.1 is pretty good if you */
- /* don't have any complicated expressions or structure references. */
- /* My using of absolute references for globals seems to do nicely. */
- /* */
- /********************************************************************************/
-
- #include "AROSE.h"
- #include "os.h"
- #include "managers.h"
-
- #include "ARDriver.h"
- #include "ARTask.h"
-
- pascal void illegal()
- extern 0x4afc;
-
- tbeint()
- {
- ++(G->tbeCount);
-
- // See if we are to send XON or XOFF.
-
- if (G->sendXOnff)
- {
- *SCCData = G->sendXOnff;
- G->sendXOnff = 0;
- G->moreTx = 1;
- return;
- }
-
- // See if handshake is okay.
-
- if ((G->swhs && G->xOffFlag) || (G->hwhs && G->CTSFlag))
- {
- *SCCControl = 0x28;
- G->moreTx = 0;
- return;
- }
-
- if (G->txCount)
- {
- --(G->txCount);
- --(G->sTxCount);
- if (G->txCount == 0)
- G->moreTx = 0;
- else
- G->moreTx = 1;
- *SCCData = *(G->txOut);
- ++(G->txOut);
- if (G->txOut == G->txLast)
- G->txOut = G->txFirst;
-
- if ((G->txCount == 0) || (G->txTickle && (--(G->txTickle) == 0)))
- {
- if (G->txSignal)
- {
- Send( G->txSignal );
- G->txSignal = 0;
- }
- else
- illegal();
- }
- return;
- }
-
- *SCCControl = 0x28;
- G->moreTx = 0;
- }
-
- escint()
- {
- unsigned char stat, chg;
-
- ++(G->escCount);
- stat = *SCCControl;
- chg = stat ^ G->prevStat;
- G->prevStat = stat;
- *SCCControl = 0x10;
-
- if (chg & 0x20) /* CTS */
- {
- G->CTSFlag = (stat & 0x20);
- if (G->hwhs && !G->CTSFlag)
- tbeint();
- }
-
- if (chg & 0x80) /* Break */
- {
- /* Terminate input request */
- }
- }
-
- rcaint()
- {
- unsigned char c;
-
- ++(G->rcaCount);
-
- // Get the data.
-
- c = *SCCData & G->charMask;
-
- // Check for PE substitution.
-
- if (G->peChar && (G->peChar == c))
- c = G->altChar;
-
- // Check for software handshake XON.
-
- if (G->swhs && (G->xOnChar == c))
- {
- if (G->xOffFlag)
- {
- G->xOffFlag = 0;
- tbeint();
- }
- return;
-
- }
-
- // Check for software handshake XOFF.
-
- if(G->swhs && (G->xOffChar == c))
- {
- G->xOffFlag = 1;
- return;
- }
-
- if (G->rxCount)
- {
- ++(G->sRxCount);
- --(G->rxCount);
- *(G->rxIn) = c;
- ++(G->rxIn);
- if (G->rxIn == G->rxLast)
- G->rxIn = G->rxFirst;
-
- if ((G->rxCount == 0) || (G->rxTickle && (--(G->rxTickle) == 0)))
- {
- if (G->rxSignal)
- {
- Send( G->rxSignal );
- G->rxSignal = 0;
- }
- }
- return;
- }
-
- G->asyncErr |= 1; /* Soft overrun */
- }
-
- srcint()
- {
- unsigned char err, c;
-
- ++(G->srcCount);
- *SCCControl = 0x01; /* Point to RR1 */
- err = *SCCControl; /* Get the error */
- G->asyncErr |= (err & 0x70); /* accumulate errors */
- c = *SCCData & G->charMask; /* Get the data */
- *SCCControl = 0x30; /* Reset the error */
-
- if (G->options & err)
- {
- if (G->rxQHead)
- {
- /* Abort current read */
- }
- return;
- }
-
- if (G->peChar && (G->peChar == c) && (err & 0x10))
- c = G->altChar;
-
- if (G->rxCount)
- {
- ++(G->sRxCount);
- --(G->rxCount);
- *(G->rxIn) = c;
- ++(G->rxIn);
- if (G->rxIn == G->rxLast)
- G->rxIn = G->rxFirst;
-
- if ((G->rxCount == 0) || (G->rxTickle && (--(G->rxTickle) == 0)))
- {
- if (G->rxSignal)
- {
- Send( G->rxSignal );
- G->rxSignal = 0;
- }
- }
- }
- }
-